<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>

<body>
<style>
    body {
        text-align: center;
    }
    .liStyle {
        width:2000px; float:left;

        margin-right: 500px;

    }
      .liStyle li{
          list-style:none; width:400px; float: left;
      }
   

</style>
<script src="https://cdn.bootcss.com/popper.js/1.14.7/umd/popper.min.js"></script>
<link href="${pageContext.request.contextPath}/css2/bootstrap.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/jquery/jquery-3.3.1.js"></script>
<script src="${pageContext.request.contextPath}/jquery/jquery.cookie.js"></script>
<script src="${pageContext.request.contextPath}/js2/bootstrap.js"></script>
<h1>商品</h1>
<div class="goods">

<ul class="liStyle">
    <c:forEach items="${goodslist}" var="one">
    <li>

        <div class="card" style="width: 18rem;">
            <img src="${pageContext.request.contextPath}/img/${one.goodsPic}" class="card-img-top" alt="...">
            <div class="card-body">
                <h6 class="card-title">${one.goodsName}</h6>
                <p class="card-text">${one.goodsDesc}</p>
                <p class="card-text" style="">￥:<s>${one.goodPrice}<span>元</span></s> <br> <span style="font-size: 20px;color: red">￥:${one.goodPrice*one.discount}元</span><br>
                <a href="#" class="btn btn-primary">加入购物车</a>
                <a onclick="buygoods(${one.goodsId},${one.goodPrice})" class="btn btn-primary ">立即购买</a>

            </div>
        </div>

    </li>
        
    </c:forEach>


</ul>

</div>

<script>
    function buygoods(id,price) {


       if(${empty loginUser.id})
       {
           alert("请先登录")
           location.reload()
           id=null;
           price=null
           pagechage(id,price)
       }
       else {

           pagechage(id,price,${loginUser.id})
       }




    }
    function pagechage(id,price,userid){
        window.location.href="${pageContext.request.contextPath}/order/addOrder?goodsId="+id+"&customerId="+userid+"&price="+price;


    }



</script>




</body>
</html>
